package jpa4azure.impl;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import jpa4azure.type.Key;

public class ObjectMeta {

	HashSet<String> dirty;
	boolean active;
	Map<String, Key> keys;
	
	public ObjectMeta() {
		dirty = new HashSet<String>();
		keys = new HashMap<String, Key>();
	}
	
	public boolean isDirty() {
		return dirty.size() > 0;
	}

	public Set<String> getDirtyProperties() {
		return dirty;
	}

	public void addDirtyProperty(String property) {
		dirty.add(property);
	}

	public void setActive() {
		active = true;
	}

	public boolean isActive() {
		return active;
	}

	public void add(String property, String partition, String row) {
		Key key = new Key(partition, row);
		keys.put(property, key);
	}

	public Key getKey(String property) {
		return keys.get(property);
	}

	public void reset() {
		dirty.clear();		
	}

}
